package cn.fl.riskctrl.corp.controller;

import java.util.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.comm.facade.upload.condition.SysUlFilesRecQueryCondition;
import cmm.mid.core.framework.dto.DataResultDTO;
import cmm.mid.core.framework.page.KeyValueVO;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.DateUtils;
import cn.cmm.cache.framework.utils.PropertiesCacheUtils;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.system.constant.SysLogConstant;
import cn.fl.system.service.ISysDictionaryService;
import cn.fl.system.service.ISysUlFilesRecService;
import cn.fl.system.vo.SysUlFilesRecVO;
import fl.constant.facade.framework.constant.DictionaryConstant;
import fl.constant.facade.framework.constant.FlowConstant;
import fl.constant.facade.framework.constant.SystemConstant;
import fl.constant.facade.framework.constant.UploadConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSONObject;

import cn.fl.riskctrl.corp.service.IRcCstCorpBscInfoService;
import cn.fl.riskctrl.corp.vo.RcCstCorpBscInfoVO;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.exception.BaseException;
import rc.corpbaseinfo.facade.corpbaseinfo.condition.RcCstCorpBscInfoQC;

/**
 * @Description: RC_CST_CORP_BSC_INFO（前置征信企业客户基础信息） 控制层
 */
@Controller
@RequestMapping("/corp/rccstcorpbscinfo")
public class RcCstCorpBscInfoController extends BaseController {

	private static final Logger logger = LoggerFactory.getLogger(RcCstCorpBscInfoController.class);

	/**
	 * RcCstCorpBscInfo 服务层BEAN
	 */
	@Autowired
	private IRcCstCorpBscInfoService rcCstCorpBscInfoService;
    @Autowired
    private ISysUlFilesRecService sysUlFilesRecService;
    @Autowired
    private ISysDictionaryService sysDictionaryService;
    @Autowired
    private ISysDictionaryApiService sysDictionaryApiService;

	/**
	 * 到列表页面
	 */
	@RequestMapping(value = "/toListPage.do", method = { RequestMethod.GET})
	public ModelAndView toListPage(HttpServletRequest request, HttpServletResponse response) {
		Long startTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "toListPage", "加载列表页面.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
        String audStsCdDic = "RCT0046";//审批状态
        String usLevelDic = PropertiesCacheUtils.getProperty(DictionaryConstant.CODE_RCT_LVL_CD);//征信评级
        String yesNoDic = PropertiesCacheUtils.getProperty(DictionaryConstant.CODE_SYS_YES_NO_CD);//是否标识
        List<String> codeGrpCdList = new ArrayList<>();
        codeGrpCdList.add(audStsCdDic);
        codeGrpCdList.add(usLevelDic);
        codeGrpCdList.add(yesNoDic);
        Map<String, List<KeyValueVO>> dicMap = this.sysDictionaryService.getMultiKvList(CurrentThreadContext.getFlServiceSysCd(), CurrentThreadContext.getCurrentOrgCd(), codeGrpCdList);
        List<KeyValueVO> list = dicMap.get(audStsCdDic);
//        List<KeyValueVO> removeList = new ArrayList<>();
//        for (KeyValueVO keyValueVO : list) {
//            if (!"1".equals(keyValueVO.getKey()) && !"2".equals(keyValueVO.getKey()) && !"3".equals(keyValueVO.getKey())) {
//                removeList.add(keyValueVO);
//            }
//        }
//        list.removeAll(removeList);
        ModelAndView view = new ModelAndView("riskctrl/corp/rcCstCorpBscInfoList");
        view.addObject("audStsCdDicList", list);

        List<KeyValueVO> usList = dicMap.get(usLevelDic);
        view.addObject("usLevelDicList", usList);

        List<KeyValueVO> yesNoList = dicMap.get(yesNoDic);
        view.addObject("yesNoDicList", yesNoList);

		Long endTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "toListPage", "加载列表页面.耗时：" + (endTm-startTm), CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 到新增修改页面
	 */
	@RequestMapping(value = "/toAddPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toAddPage(HttpServletRequest request, HttpServletResponse response) {
		Long startTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "toAddPage", "加载新增.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
		
		ModelAndView view = new ModelAndView("corp/rcCstCorpBscInfo/rcCstCorpBscInfoAdd");
		
		Long endTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "toAddPage", "加载新增.耗时：" + (endTm-startTm), CurrentThreadContext.getCurrentUserName());
		return view;
	}

	/**
	 * 到修改页面
	 */
	@RequestMapping(value = "/toModifyPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toModifyPage(HttpServletRequest request, HttpServletResponse response) {
		Long startTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "toAddPage", "加载修改页面.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
		
		String id = request.getParameter("id");
		ModelAndView view = new ModelAndView("corp/rcCstCorpBscInfo/rcCstCorpBscInfoModify");
		view.addObject("id", id);
		Long endTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "toAddPage", "加载修改.耗时：" + (endTm-startTm), CurrentThreadContext.getCurrentUserName());
		return view;
	}
	
	/**
	 * 到详情页面
	 */
	@RequestMapping(value = "/toDetailPage.do", method = { RequestMethod.GET})
	public ModelAndView toDetailPage(HttpServletRequest request, HttpServletResponse response) {
		Long startTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "toDetailPage", "加载例子详细页面.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
		
		String id = request.getParameter("id");
		ModelAndView view = new ModelAndView("corp/rcCstCorpBscInfo/rcCstCorpBscInfoDetail");
		view.addObject("id", id);
		
		Long endTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "toDetailPage", " 加载例子详细页面.耗时：" + (endTm-startTm), CurrentThreadContext.getCurrentUserName());
		return view;
	}

	/**
	 * 跳转到前置征信复议页面
	 */
	@RequestMapping(value = "/toAuditPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toAuditPage(HttpServletRequest request, HttpServletResponse response) {
		// 客户ID
		String id = request.getParameter("id");

		// 跳转页面标识
		String zx_flag = request.getParameter("zx_flag");
		String viewUrl = "riskctrl/corp/auditPage2";
		if(null != zx_flag) {
			if("1".equals(zx_flag)) {
				// 完整功能
				viewUrl = "riskctrl/corp/auditPage1";
			}
			if("2".equals(zx_flag)){
				// 仅报告
				viewUrl = "riskctrl/corp/auditPage2";
			}
		}
		ModelAndView view = new ModelAndView(viewUrl);
		// 前置客户ID
		view.addObject("zx_cstid", id);
		// 上传文件路径
		String path = PropertiesCacheUtils.getProperty(UploadConstant.UPLOAD_SERVER_PATH);
		view.addObject("zx_path", path);

		BaseLogUtils.info(logger, "toAuditPage", "跳转到前置征信复议页面.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
		return view;
	}

	/**
	 * 初始化列表
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initList(HttpServletRequest request, HttpServletResponse response) {
		Long startTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "initList", "加载列表页面.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
		
		
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		String cstNm = request.getParameter("cstNm");
		String certTypCd = request.getParameter("certTypCd");
		String certNo = request.getParameter("certNo");
		String cstMgrNm = request.getParameter("cstMgrNm");
		String stDt = request.getParameter("stDt");
        String endDt = request.getParameter("endDt");
        String audStsCd = request.getParameter("audStsCd");
        String rskLvlCd = request.getParameter("rskLvlCd");
        String isReaud = request.getParameter("isReaud");

		RcCstCorpBscInfoQC qc = new RcCstCorpBscInfoQC();
		if (StringUtils.isNotEmpty(cstNm)) {
            qc.setCstNm(cstNm);
		}
		if (StringUtils.isNotEmpty(certTypCd)) {
            qc.setCertTypCd(certTypCd);
		}
		if (StringUtils.isNotEmpty(certNo)) {
            qc.setCertNo(certNo);
		}
		if (StringUtils.isNotEmpty(cstMgrNm)) {
            qc.setCstMgrNm(cstMgrNm);
		}
		if (StringUtils.isNotEmpty(stDt)) {
            Date beginDate = DateUtils.formatStringToDate(stDt, DateUtils.YYYY_MM_DD);
            qc.setStDt(beginDate);
		}
		if (StringUtils.isNotEmpty(endDt)) {
            Date endDate = DateUtils.formatStringToDate(endDt, DateUtils.YYYY_MM_DD);
            qc.setEndDt(endDate);
		}
		if (StringUtils.isNotEmpty(audStsCd)) {
            qc.setAudStsCd(audStsCd);
		}
		if (StringUtils.isNotEmpty(rskLvlCd)) {
            qc.setRskLeveCd(rskLvlCd);
		}
		if (StringUtils.isNotEmpty(isReaud)) {
            qc.setIsReaud(Integer.valueOf(isReaud));
		}
//		qc.setPid("8c9dee73938a483c9909d11c2f74bd17");
//		qc.setBid("41aca9fb05f74dd28e174a903ce50186");

		Pager pager = this.rcCstCorpBscInfoService.searchListPage(Integer.valueOf(pageSize), Integer.valueOf(currentPage), qc);
		List<RcCstCorpBscInfoVO> list = (List<RcCstCorpBscInfoVO>) pager.getResultList();

		//查询图片信息
		List<String> pkList = new ArrayList<>();
		for (RcCstCorpBscInfoVO rcCstCorpBscInfoVO : list) {
			pkList.add(String.valueOf(rcCstCorpBscInfoVO.getId()));
		}

		SysUlFilesRecQueryCondition condition = new SysUlFilesRecQueryCondition();
		condition.setPkIdList(pkList);
		condition.setSysCd(CurrentThreadContext.getCurrentSysCd());//系统代码-必须条件
		List<SysUlFilesRecVO> sysUlFilesRecList = this.sysUlFilesRecService.searchList(condition);

        Map<String, List<SysUlFilesRecVO>> map = new HashMap<>();
        for (RcCstCorpBscInfoVO rcCstCorpBscInfoVO : list) {
            List<SysUlFilesRecVO> fileList = new ArrayList<>();
            for (SysUlFilesRecVO sysUlFilesRecVO: sysUlFilesRecList) {
                if (sysUlFilesRecVO.getPkId().equals(rcCstCorpBscInfoVO.getId().toString())) {
                    fileList.add(sysUlFilesRecVO);
                }
            }
            map.put(rcCstCorpBscInfoVO.getId().toString(), fileList);
        }

        for (RcCstCorpBscInfoVO rcCstCorpBscInfoVO : list) {
            rcCstCorpBscInfoVO.setFileList(map.get(rcCstCorpBscInfoVO.getId().toString()));
        }
		ListPageVO<RcCstCorpBscInfoVO> listPage = new ListPageVO<>(list, pager.getTotalCount());
		Long endTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "initList", "加载列表页面.耗时：" + (endTm-startTm), CurrentThreadContext.getCurrentUserName());
		return listPage;
	}
	
	/**
	 * 新增
	 */
	@RequestMapping(value = "/add.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object add(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		Long startTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "add", "新增对象.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
		
		String name = request.getParameter("name");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "新增成功!");
		RcCstCorpBscInfoVO entity = null;
		try {
			entity = new RcCstCorpBscInfoVO();
			//TODO ADD PARAM
			Long id = this.rcCstCorpBscInfoService.add(entity);
			result.setData(id);
			BaseLogUtils.info(logger, "add", "新增数据.[id="+id+"] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "add", "新增对象失败,name["+name+"].", CurrentThreadContext.getCurrentUserName(), ex);
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("系统错误,请联系管理员!");
			BaseLogUtils.error(logger, "add", "新增对象失败,name["+name+"].", CurrentThreadContext.getCurrentUserName(), ex);
		}
		Long endTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "add", "新增对象.耗时：" + (endTm-startTm), CurrentThreadContext.getCurrentUserName());
		
		return result;
	}

	/**
	 * 修改
	 */
	@RequestMapping(value = "/modify.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modify(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		Long startTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "modify", "修改对象.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());

        String id = request.getParameter("id");
        String audOpinion = request.getParameter("audOpinion");
        String audOpinion2 = request.getParameter("audOpinion2");
        String rskLvlCd = request.getParameter("rskLvlCd");
        String audStsDesc = request.getParameter("audStsDesc");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "修改成功!");
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("数据不存在!");
			BaseLogUtils.info(logger, "modify", "修改数据,主键不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		RcCstCorpBscInfoVO entity = null;
		try {
			entity = new RcCstCorpBscInfoVO();
			entity.setId(Long.valueOf(id));
            if (StringUtils.isNotEmpty(audOpinion)) {
                entity.setAudOpinion(audOpinion.trim());
            }
            if (StringUtils.isNotEmpty(audOpinion2)) {
                entity.setAudOpinion2(audOpinion2.trim());
            }
            if (StringUtils.isNotEmpty(rskLvlCd)) {
				List<String> codeGrpCdList = new ArrayList<>();
				String rskLvlCdDic = "ODR0030";
				codeGrpCdList.add(rskLvlCdDic);
				Map<String, String> rskLvlCdMap  = new HashMap<>();
				Map<String, Map<String, String>> dicMap;
				String sysCd = PropertiesCacheUtils.getProperty(SystemConstant.FL_SERVICE_CD);
				String orgCd = PropertiesCacheUtils.getProperty(SystemConstant.FL_ORG_CD);
				dicMap = this.sysDictionaryApiService.searchMultiGroupToMap(sysCd, orgCd, codeGrpCdList);
				if(dicMap.containsKey(rskLvlCdDic)){
					rskLvlCdMap = dicMap.get(rskLvlCdDic);
					if(CollectionUtils.isMapEmpty(rskLvlCdMap)){
						rskLvlCdMap = new HashMap<>();
					}
				}
				entity.setIsReaud(1);
                entity.setRskLeveDesc(rskLvlCdMap.get(rskLvlCd));
                entity.setRskLeveCd(rskLvlCd.trim());
                String audPass = PropertiesCacheUtils.getProperty(FlowConstant.FLOW_CHECK_STATE_PASS);
                String audNoPass = PropertiesCacheUtils.getProperty(FlowConstant.FLOW_CHECK_STATE_NO_PASS);
                if ("1".equals(rskLvlCd.trim()) || "2".equals(rskLvlCd.trim())|| "4".equals(rskLvlCd.trim())|| "5".equals(rskLvlCd.trim())) {
                    // A级通过、B级有条件通过、
                    entity.setAudStsCd(audPass);  // 通过
                } else if ("3".equals(rskLvlCd.trim())) {
                    // C级直接拒单
                    entity.setAudStsCd(audNoPass);  // 不通过
                }
            }
            if (StringUtils.isNotEmpty(audStsDesc)) {
                entity.setAudStsDesc(audStsDesc.trim());
            }
			boolean success = this.rcCstCorpBscInfoService.modify(entity);
			if(!success){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo("修改失败!");
				BaseLogUtils.info(logger, "modify", "修改失败.[id="+id+"] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
			}
			BaseLogUtils.info(logger, "modify", "修改成功.[id="+id+"] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "modify", "修改对象失败,id["+id+"].", CurrentThreadContext.getCurrentUserName(),ex);
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("系统错误,请联系管理员!");
			BaseLogUtils.error(logger, "modify", "修改对象失败,id["+id+"].", CurrentThreadContext.getCurrentUserName(),ex);
		}
		
		Long endTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "modify", "修改对象.耗时：" + (endTm-startTm), CurrentThreadContext.getCurrentUserName());

		return result;
	}

	/**
	 * 得到一条记录
	 * 
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getById.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		Long startTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "getById", "根据主键获取对象.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
		
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "操作成功!");
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("主键不能为空!");
			BaseLogUtils.error(logger, "getById", "获取数据,主键不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		
		try {
			RcCstCorpBscInfoVO vo = this.rcCstCorpBscInfoService.selectById(Long.valueOf(id));
			if(null == vo){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo("数据不存在!");
				BaseLogUtils.info(logger, "getById", "获取数据,数据不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
			}
			result.setData(vo);
			BaseLogUtils.info(logger, "getById", "获取数据.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "getById", "根据主键获取对象失败,主键["+id+"].", CurrentThreadContext.getCurrentUserName(),ex);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("系统错误,请联系管理员!");
			BaseLogUtils.error(logger, "getById", "根据主键获取对象失败,主键["+id+"].", CurrentThreadContext.getCurrentUserName(),ex);
		}
		
		Long endTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "getById", "根据主键获取对象.耗时：" + (endTm-startTm), CurrentThreadContext.getCurrentUserName());

		return result;
	}

	/**
	 * 获取拒单规则信息
	 */
	@RequestMapping(value = "/getRiskCtrlData.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object getRiskCtrlData(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		Long startTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "getRiskCtrlData", " 获取风控数据.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
		String cstId = request.getParameter("cstId");//客户ID

		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if (StringUtils.isEmpty(cstId)) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("获取企业征信客户ID不能为空!");
			BaseLogUtils.info(logger, "getRiskCtrlData", this.getRequestParameter(request));
			return result;
		}
		try {
			DataResultDTO data = this.rcCstCorpBscInfoService.getRiskCtrlData(Long.valueOf(cstId));
			result.setData(data.getData());
		} catch (BaseException ex) {
			BaseLogUtils.error(logger, "-", "异常", ex);
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "getRiskCtrlData", "获取数据失败!" + this.getRequestParameter(request) + ", ERROR : " + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		} catch (Exception ex) {
			BaseLogUtils.error(logger, "-", "异常", ex);
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "getRiskCtrlData", "获取数据失败!" + this.getRequestParameter(request) + ", ERROR : " + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		Long endTm = System.currentTimeMillis();
		BaseLogUtils.info(logger, "getRiskCtrlData", " 获取风控数据.耗时：" + (endTm-startTm), CurrentThreadContext.getCurrentUserName());
		return result;
	}

    /**
     * 获取信加企业本地规则
     */
    @RequestMapping(value = "/getXjCorpLocalData.do", method = { RequestMethod.GET })
    @ResponseBody
    public Object getXjCorpLocalData(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "getXjCorpLocalData", " 获取信加企业数据.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
        String cstId = request.getParameter("cstId");//客户ID
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
        if (StringUtils.isEmpty(cstId)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("获取征信企业数据客户ID不能为空!");
            BaseLogUtils.info(logger, "getXjCorpLocalData", this.getRequestParameter(request));
            return result;
        }
        try {
            DataResultDTO data = this.rcCstCorpBscInfoService.getXjCorpLocalData(Long.valueOf(cstId));
            result.setData(data.getData());
        } catch (BaseException ex) {
            ex.getStackTrace();
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.info(logger, "getXjCorpLocalData", "获取数据失败!" + this.getRequestParameter(request) + ", ERROR : " + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            ex.getStackTrace();
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.error(logger, "getXjCorpLocalData", "获取数据失败!" + this.getRequestParameter(request) + ", ERROR : " + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "getXjCorpLocalData", " 获取信加企业数据.耗时：" + (endTm-startTm), CurrentThreadContext.getCurrentUserName());
        return result;
    }
}

